class Container {
  constructor(v) {
    this._value = v;
  }

  static of(value) {
    return new Container(value);
  }

  map(fn) {
    return Container.of(fn(this._value));
  }
}

class MayBe {
  constructor(value) {
    this.__value = value;
  }
  static of(value) {
    return new MayBe(value);
  }
  map(fn) {
    return this.isNothing() ? this : MayBe.of(fn(this.__value));
  }

  isNothing() {
    return this.__value === null || this.__value === undefined;
  }
}

module.exports = {
  Container,
  Maybe: MayBe,
};
